package com.lgs.xlistviewtest.view.item;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.ViewGroup;
import android.widget.TextView;

import com.lgs.common.widgets.xlist.BaseListItem;
import com.lgs.common.widgets.xlist.IOnClickItemListener;
import com.lgs.xlistviewtest.BR;
import com.lgs.xlistviewtest.R;
import com.lgs.xlistviewtest.module.bean.DataItem;

public class XListItem<T> extends BaseListItem<T> {

    @SuppressLint("InflateParams")
    public XListItem(Context context, int layout, ViewGroup parent) {
        super(context, layout, parent);
    }

    public void setListItem(int position, T item, IOnClickItemListener onClickListener) {
        super.setListItem(position, item, onClickListener);

        DataItem data = (DataItem) item;

        if (binding != null) {
            binding.setVariable(BR.data, data);

            // ((ListItemDataBinding)binding).setData(data);
            // //binding.executePendingBindings();//绑定之后强制刷新
            // ((ListItemDataBinding)binding).tvName.setText(data.getName());
        }
        else
        {
           TextView tvName = itemView.findViewById(R.id.tv_name);
           tvName.setText(data.getName());
        }
//
//        tvName.setTag(R.id.tag_row, position);
//        tvName.setTag(R.id.tag_col, 0);
//        tvName.setOnClickListener(this);
    }

}
